<template>
  <div class="app-container">
    <el-tabs type="border-card" :value="activeTab" @tab-click="changeTab">
      <el-tab-pane v-if="roleCheck('list')" name="one" label="活动查询">
        <list v-show="activeTab === 'one'"></list>
      </el-tab-pane>
      <el-tab-pane v-if="roleCheck('config')" name="two" label="活动配置">
        <config v-show="activeTab === 'two'"></config>
      </el-tab-pane>
      <el-tab-pane v-if="roleCheck('assign-reward')" name="three" label="指定中奖">
        <assign-prize v-show="activeTab === 'three'"></assign-prize>
      </el-tab-pane>
      <el-tab-pane v-if="roleCheck('receive-info')" name="four" label="收货信息">
        <receive-info v-show="activeTab === 'four'"></receive-info>
      </el-tab-pane>
    </el-tabs>
  </div>
</template>

<script>
import { tabs } from '@/build';
import config from './config';
import list from './list';
import assignPrize from './assignPrize';
import receiveInfo from './receiveInfo.vue';

export default {
  name: 'index',
  components: {
    config, list, assignPrize, receiveInfo,
  },
  mixins: [tabs],
  data() {
    return {
      activeTab: 'one',
    };
  },
  mounted() {
    if (this.roleCheck('list')) {
      this.activeTab = 'one';
    } else if (this.roleCheck('config')) {
      this.activeTab = 'two';
    } else if (this.roleCheck('assign-reward')) {
      this.activeTab = 'three';
    } else if (this.roleCheck('receive-info')) {
      this.activeTab = 'four';
    }
  },
  methods: {
    changeTab(tabs) {
      this.activeTab = tabs.name;
    },
  },
};
</script>

<style scoped>

</style>
